home *** CD-ROM | disk | FTP | other *** search
- %OP%VS4.11 (04-Dec-91), Gerald Lewis Fitton, R4000 5065 0380 9644
- %OP%DP0
- %OP%IRY
- %OP%PL0
- %OP%HM0
- %OP%FM0
- %OP%BM0
- %OP%LM4
- %OP%FX
- %OP%FY
- %OP%FS
- %OP%PT1
- %OP%PDPipeLine
- %OP%WC810,2050,180,1620,0,0,0,0
- %CO:A,72,72%
- %C%Arrays - Part 1
- %C%by Gerald L Fitton
- Keywords:
- Array Matrix Fitton
-
- The directory "Array01" is the first on this disc because the word
- "Array" starts with "A", the first letter of the alphabet. However,
- the content of this directory might not be the best to study first. I
- suggest that the files in PipeDream4 and Documents should be read first
- followed by those in the directory BusLetter. If you are unfamiliar
- with PipeDream 3 spreadsheets then you may benefit from reading the
- Sheets series before the Array series.
-
- What is a PipeDream 4 Array?
- Load the file [Array01] from this directory. A "Range" is a range of
- slots. The range [Array01]B2C6 contains the ten numbers (1 to 10). In
- PipeDream 3 you would have to address each of these slots individually
- but in PipeDream 4 we can treat the range as a single entity. The
- range can be given a variable name and the name operated on by an array
- function. Before we get into such complications let's see how I've
- loaded the whole range into a single slot so that [Array01]B10 contains
- a 5 by 2 array of the numbers in the range B2C6.
-
- Transferring Values from a Range to an Array
- There are three ways of transferring values from a range to an array.
- The file [Array01] shows what I believe to be the easiest way.
-
- If you click the mouse select (left) button in slot [Array01]B10 then
- you will see the formula I have used to store the range in the array.
-
- You can experiment yourself by loading [Array01z]. The caret is ready
- positioned in slot [Array01z]B10. If it isn't there (because I've made
- a mistake when I saved the file) then place the caret in slot B10 using
- the pointer and the mouse (position the pointer over slot B10 and click
- the mouse select button). Next, use the mouse to position the pointer
- in the formula line, position the pointer in B2 and click select,
- repeat this process in C6 to specify the range, finally, click on the
- green tick to transfer the formula from the formula line to the slot.
-
- Alternative methods
- The file [Array01b] shows a second method which uses the function
- set_value(slot, range). Again you can experiment with [Array01z].
- This time, after clicking in the formula line click select over the
- formula button (the italic f), run the pointer through misc (for
- miscellaneous functions) and click on set_value. Click on B10, click
- in the formula line just after the comma which separates the two
- arguments, click on the two ends of the range, B2C6, and finally on the
- green tick. Easy, isn't it?
-
- The third method is messy but it allows me to explain the Pipedream 4
- index function which is different from the PipeDream 3 function of the
- same name. Load [Array01b] and look at the formula in B10. In
- PipeDream 4 index has the syntax index(range,col,row,cols,rows) and it
- can be used to transfer part (or, in this case, all) of a range into an
- array. In PipeDream 3 the function index has only two arguments, a
- column number and a row number (note that column A = 1, B = 2, C = 3,
- etc). In PipeDream 4 the index function has three obligatory and two
- optional arguments. The first argument is a range or an array
- (generally, in PipeDream 4 arrays and ranges are interchangeable -
- hence my surprise to find PipeDream 4 crashed when I tried to enter a
- range in an array slot). I have entered B2C6 as the range to be
- transferred to the array. The second and third arguments of index
- allow you to transfer only part of the range to the array; they are the
- "coordinates" of the "first" element of the range which you want
- transferred to the top left corner of the array. I have used
- index(range,1,1,cols,rows); ie I have made col = 1 and row = 1 so that
- the top left element of the range (slot B2) is the first element (top
- left corner) of the array. If I had used index(range,1,3,cols,rows)
- then the first two rows of the range (which contain the numbers 1, 6, 2
- and 7) would not be transferred to the array. If you like to
- experiment then try changing the index function to index(B2C6,1,3,1,3)
- and see what happens.
-
- The size of the range is 2 columns and 5 rows. To transfer all the
- range of 2 columns and 5 rows to the array in [Array01b]B10 I must use
- 2 and 5 as the fourth and fifth arguments of the index function. If
- you use values for these arguments that are less than the number of
- columns and rows in the range then you will transfer only part of the
- range to the array. For simplicity I could have written my index
- function as index(range,1,1,2,5), (ie with cols = 2 and with rows = 5)
- and the range would be transferred into the array but then, if I
- changed the size of the range from a 5 by 2 matrix to say a 6 by 2 (eg
- by inserting an extra row with <F7>) then I would have had to change
- the last argument of my index function from 5 to 6. One maxim of good
- spreadsheet (and programming) practice is "Never use a value when you
- can use a variable". Instead I have uses the functions cols and rows
- to calculate the numbers of columns and rows of the range.
-
- Taking a Snapshot of an Array
- I would have liked to snapshot slot [Array01]B10 and then deleted the
- range [Array01]B2C6 but, when I tried this in version 4.11 I found that
- the array in [Array01]B10 became a single value. The rest of the array
- disappeared! The benefit I can see for such a sequence of operations
- is that I could enter the data making up the range in a dependent
- document, hide it in an array which is then snapshotted, etc. Perhaps
- in a later version of PipeDream 4.
-
- Transferring Values from an Array to a Range
- The function set_value is the easiest way I have found of transferring
- the whole of an array to a range. I have entered that function into
- slot B12. The syntax of set_value is set_value(to,from). Generally
- "to" and "from" are slot references but, if "to" is a range and "from"
- is the slot containing an array then as much as possible of the array
- as will fit the range is transferred to the range.
-
- Recovering a Single Value from an Array
- Sometimes you may want to recover only one value from an array. The
- index function can be used to do this. In slot [Array01]B20 I have
- used the index function to recover the value from column 2, row 4 of
- the array stored in slot [Array01]B10.
-
- Over to You
- Experiment with this spreadsheet. You can insert additional rows into
- the range [Array01]B2C6 with <F7>. However, if you do insert a row
- then beware that I have not written the formula in slot [Array01]B12
- (for recovering the array) in its most "general" form. Because of this
- you will have to alter the space allocated to the output range by
- inserting a row somewhere between row 12 and row 16 with <F7> to match
- the extra row you have inserted between rows 2 and 6. You can insert a
- column between B and C using <Ctrl EIC> with impunity!
-